import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fluttermodule/utils/screen.dart';

class LearningMaterialsWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    setScreenSize(context);
    return SingleChildScrollView(
      child: Column(
        children: <Widget>[
          _LearnIntroduction(),
          _LearnEvaluate(),
          _Leaderboard(),
          _LearnList()
        ],
      ),
    );
  }

  Widget _LearnIntroduction() {
    return Container(
      padding: EdgeInsets.only(top: dpHeight(30)),
      margin: EdgeInsets.only(bottom: dpHeight(15)),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Row(
            children: <Widget>[
              Container(
                margin: EdgeInsets.only(right: dpHeight(20)),
                width: dpWidth(12),
                height: dpHeight(32),
                color: Color.fromARGB(255, 211, 177, 127),
              ),
              Text(
                "万亿级的赛道中如何错位竞争",
                style: TextStyle(
                    fontWeight: FontWeight.bold, fontSize: spFont(34)),
              )
            ],
          ),
          Padding(
            padding: EdgeInsets.only(left: dpWidth(32), top: dpHeight(8)),
            child: Text(
              "黄建明  顶呱呱集团董事长、五星讲师",
              style: TextStyle(fontSize: spFont(26)),
            ),
          ),
          Padding(
            padding: EdgeInsets.only(
                left: dpWidth(32),
                top: dpHeight(30),
                right: dpWidth(34),
                bottom: dpHeight(40)),
            child: Text(
              "职场人必上的互联网创新商学院,以哲科思维为根基,为你打造专业课程:互联网创新、商业模式、战略管理。",
              style: TextStyle(fontSize: spFont(26)),
            ),
          )
        ],
      ),
      color: Colors.white,
    );
  }

  Widget _LearnEvaluate() {
    return Container(
      padding: EdgeInsets.only(bottom: dpHeight(40), top: dpHeight(40)),
      margin: EdgeInsets.only(bottom: dpHeight(15)),
      child: Column(
        children: <Widget>[
          Container(
            child: Flex(
              crossAxisAlignment: CrossAxisAlignment.center,
              direction: Axis.horizontal,
              children: <Widget>[
                Container(
                  margin: EdgeInsets.only(right: dpHeight(20)),
                  width: dpWidth(12),
                  height: dpHeight(32),
                  color: Color.fromARGB(255, 211, 177, 127),
                ),
                Expanded(
                    child: Text(
                  "课程评价(121)",
                  style: TextStyle(
                      fontWeight: FontWeight.bold, fontSize: spFont(34)),
                )),
                Padding(
                  padding: EdgeInsets.only(right: dpWidth(28), top: 2),
                  child: Text('查看更多'),
                )
              ],
            ),
            margin: EdgeInsets.only(bottom: dpHeight(47)),
          ),
          Row(
            children: <Widget>[
              Container(
                margin: EdgeInsets.only(left: dpWidth(32), right: dpWidth(22)),
                width: dpWidth(80),
                height: dpWidth(80),
                alignment: Alignment.center,
                child: Text(
                  "浩",
                  style: TextStyle(color: Colors.white, fontSize: spFont(40)),
                  textAlign: TextAlign.center,
                ),
                decoration: BoxDecoration(
                    color: Color.fromARGB(255, 211, 177, 127),
                    borderRadius: BorderRadius.circular(dpWidth(80))),
              ),
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                mainAxisSize: MainAxisSize.max,
                children: <Widget>[
                  Row(
                    children: <Widget>[
                      Text(
                        '刘浩',
                        style: TextStyle(
                            fontSize: spFont(28), fontWeight: FontWeight.bold),
                      ),
                      Padding(
                        padding: EdgeInsets.only(left: dpWidth(17)),
                        child: Text(
                          "互联网后台客服部",
                          style: TextStyle(
                              color: Color.fromARGB(255, 153, 153, 153),
                              fontSize: spFont(24)),
                        ),
                      )
                    ],
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.start,
                    children: _stars(),
                  )
                ],
              )
            ],
          ),
          Container(
              margin: EdgeInsets.only(
                  top: dpHeight(30),
                  left: dpWidth(134),
                  right: dpWidth(43),
                  bottom: dpHeight(36)),
              child: Text(
                '写了《浅谈混沌与得到》一文,没有推送,也没有报名专题,自己写了就放在那,不知不觉中浏览数将近2万了,不时有朋友留言,想再解读一下混沌与得到。',
                style: TextStyle(
                    color: Color.fromARGB(255, 51, 51, 51),
                    fontSize: spFont(28)),
              )),
          OutlineButton(
            onPressed: () {},
            child: Padding(
              padding: EdgeInsets.only(
                  bottom: dpHeight(2), left: dpWidth(15), right: dpWidth(15)),
              child: Text(
                '我也要评价',
                style: TextStyle(
                    color: Color.fromARGB(255, 211, 177, 127),
                    fontWeight: FontWeight.normal,
                    fontSize: spFont(28)),
              ),
            ),
            shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(20.0)),
            borderSide: BorderSide(color: Color.fromARGB(255, 211, 177, 127)),
          )
        ],
      ),
      color: Colors.white,
    );
  }

  List<Widget> _stars() {
    var list = <Widget>[];
    for (var i = 0; i < 5; i++) {
      list.add(Container(
        child: Image.asset(
          "assets/university/images/star.png",
          width: dpWidth(28),
          height: dpHeight(28),
        ),
      ));
    }
    list.add(Container(
      margin: EdgeInsets.only(left: dpWidth(20)),
      child: Text(
        "5.0",
        style: TextStyle(
            fontSize: spFont(24), color: Color.fromARGB(255, 208, 174, 121)),
      ),
    ));
    return list;
  }

  Widget _Leaderboard() {
    return Container(
      padding: EdgeInsets.only(bottom: dpHeight(40), top: dpHeight(40)),
      margin: EdgeInsets.only(bottom: dpHeight(15)),
      child: Column(
        children: <Widget>[
          Container(
            child: Flex(
              crossAxisAlignment: CrossAxisAlignment.center,
              direction: Axis.horizontal,
              children: <Widget>[
                Container(
                  margin: EdgeInsets.only(right: dpHeight(20)),
                  width: dpWidth(12),
                  height: dpHeight(32),
                  color: Color.fromARGB(255, 211, 177, 127),
                ),
                Expanded(
                    child: Text(
                  "爱学习的呱仔",
                  style: TextStyle(
                      fontWeight: FontWeight.bold, fontSize: spFont(34)),
                )),
                Padding(
                  padding: EdgeInsets.only(right: dpWidth(28), top: 2),
                  child: Text('查看更多'),
                )
              ],
            ),
            margin: EdgeInsets.only(bottom: dpHeight(47)),
          ),
          Flex(
            direction: Axis.horizontal,
            crossAxisAlignment: CrossAxisAlignment.end,
            children: <Widget>[
              Container(
                margin: EdgeInsets.only(left: dpWidth(86)),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Container(
                      width: dpWidth(115),
                      height: dpWidth(115),
                      alignment: Alignment.center,
                      child: Text(
                        "周",
                        style: TextStyle(
                            color: Colors.white, fontSize: spFont(40)),
                        textAlign: TextAlign.center,
                      ),
                      decoration: BoxDecoration(
                          color: Color.fromARGB(255, 202, 202, 202),
                          borderRadius: BorderRadius.circular(dpWidth(80))),
                    ),
                    Padding(
                      padding: EdgeInsets.only(
                          top: dpHeight(10), bottom: dpHeight(7)),
                      child: Text(
                        "周月鸟",
                        style: TextStyle(
                            fontSize: spFont(28), fontWeight: FontWeight.bold),
                      ),
                    ),
                    Text(
                      '监督专员',
                      style: TextStyle(
                          fontSize: spFont(24),
                          color: Color.fromARGB(255, 153, 153, 153)),
                    )
                  ],
                ),
              ),
              Expanded(
                  child: Container(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Container(
                      width: dpWidth(136),
                      height: dpWidth(136),
                      alignment: Alignment.center,
                      child: Text(
                        "李",
                        style: TextStyle(
                            color: Colors.white, fontSize: spFont(40)),
                        textAlign: TextAlign.center,
                      ),
                      decoration: BoxDecoration(
                          color: Color.fromARGB(255, 211, 177, 127),
                          borderRadius: BorderRadius.circular(dpWidth(80))),
                    ),
                    Padding(
                      padding: EdgeInsets.only(
                          top: dpHeight(10), bottom: dpHeight(7)),
                      child: Text(
                        "李雪峰",
                        style: TextStyle(
                            fontSize: spFont(28), fontWeight: FontWeight.bold),
                      ),
                    ),
                    Text(
                      '人事行政主管',
                      style: TextStyle(
                          fontSize: spFont(24),
                          color: Color.fromARGB(255, 153, 153, 153)),
                    )
                  ],
                ),
              )),
              Container(
                margin: EdgeInsets.only(right: dpWidth(86)),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Container(
                      width: dpWidth(115),
                      height: dpWidth(115),
                      alignment: Alignment.center,
                      child: Text(
                        "魏",
                        style: TextStyle(
                            color: Colors.white, fontSize: spFont(40)),
                        textAlign: TextAlign.center,
                      ),
                      decoration: BoxDecoration(
                          color: Color.fromARGB(255, 219, 176, 121),
                          borderRadius: BorderRadius.circular(dpWidth(80))),
                    ),
                    Padding(
                      padding: EdgeInsets.only(
                          top: dpHeight(10), bottom: dpHeight(7)),
                      child: Text(
                        "魏晓丽",
                        style: TextStyle(
                            fontSize: spFont(28), fontWeight: FontWeight.bold),
                      ),
                    ),
                    Text(
                      '监督专员',
                      style: TextStyle(
                          fontSize: spFont(24),
                          color: Color.fromARGB(255, 153, 153, 153)),
                    )
                  ],
                ),
              )
            ],
          )
        ],
      ),
      color: Colors.white,
    );
  }

  Widget _LearnList() {
    return Container(
      padding: EdgeInsets.only(bottom: dpHeight(20), top: dpHeight(20)),
      color: Colors.white,
      child: Column(
        children: <Widget>[
          Container(
            child: Flex(
              crossAxisAlignment: CrossAxisAlignment.center,
              direction: Axis.horizontal,
              children: <Widget>[
                Container(
                  margin: EdgeInsets.only(right: dpHeight(20)),
                  width: dpWidth(12),
                  height: dpHeight(32),
                  color: Color.fromARGB(255, 211, 177, 127),
                ),
                Expanded(
                    child: Text(
                  "近期学习",
                  style: TextStyle(
                      fontWeight: FontWeight.bold, fontSize: spFont(34)),
                )),
              ],
            ),
            margin: EdgeInsets.only(bottom: dpHeight(20)),
          ),
          LearningItemWidget(),
          LearningItemWidget(),
          LearningItemWidget(),
          LearningItemWidget(),
          LearningItemWidget()
        ],
      ),
    );
  }
}

class LearningItemWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(top: dpHeight(20),bottom: dpHeight(20)),
      child: Row(
        children: <Widget>[
          Container(
            margin: EdgeInsets.only(left: dpWidth(32), right: dpWidth(22)),
            width: dpWidth(80),
            height: dpWidth(80),
            alignment: Alignment.center,
            child: Text(
              "浩",
              style: TextStyle(color: Colors.white, fontSize: spFont(40)),
              textAlign: TextAlign.center,
            ),
            decoration: BoxDecoration(
                color: Color.fromARGB(255, 211, 177, 127),
                borderRadius: BorderRadius.circular(dpWidth(80))),
          ),
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisSize: MainAxisSize.max,
            children: <Widget>[
              Row(
                children: <Widget>[
                  Text(
                    '刘浩',
                    style: TextStyle(
                        fontSize: spFont(28), fontWeight: FontWeight.bold),
                  ),
                  Padding(
                    padding: EdgeInsets.only(left: dpWidth(17)),
                    child: Text(
                      "互联网后台客服部",
                      style: TextStyle(
                          color: Color.fromARGB(255, 153, 153, 153),
                          fontSize: spFont(24)),
                    ),
                  )
                ],
              ),
              Text.rich(TextSpan(children: [
                TextSpan(
                    text: "最近学习了这个课程 ",
                    style: TextStyle(
                        color: Color.fromARGB(255, 153, 153, 153),
                        fontSize: spFont(24))),
                TextSpan(
                    text: "06-25 15:17",
                    style: TextStyle(
                        color: Color.fromARGB(255,208,174,121),
                        fontSize: spFont(24)))
              ]))
            ],
          )
        ],
      ),
    );
  }
}
